﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PingPongMain
{
    public static class AIMovement
    {
        public static void MoveBall(Ball ball)
        {
            if (ball.GameObjCoords.Row == 0)
            {
                ball.BallDirectionUp = false;
            }
            if (ball.GameObjCoords.Row == Console.WindowHeight - 3)
            {
                ball.BallDirectionUp = true;
            }
            if (ball.BallDirectionUp)
            {
                ball.GameObjCoords.Row--;
            }
            else
            {
                ball.GameObjCoords.Row++;
            }

            if (ball.BallDirectionRight)
            {
                ball.GameObjCoords.Col++;
            }
            else
            {
                ball.GameObjCoords.Col--;
            }
        }
        public static void MoveAIPaddle(Paddle paddle, Ball ball, int difficulty)
        {
            if (TomCatPingPongMain.rand.Next(1, 101) < 20 * difficulty)
            {
                if (ball.BallDirectionUp && paddle.GameObjCoords.Row > 0)
                {
                    paddle.GameObjCoords.Row--;
                }
                if (!ball.BallDirectionUp && paddle.GameObjCoords.Row + paddle.Length < PrepareField.WorldRows - 2)
                {
                    paddle.GameObjCoords.Row++;
                }
            }
        }
        public static void MoveBonus(Bonus bonus)
        {
            if (bonus.GameObjCoords.Col > 0)
            {
                bonus.GameObjCoords.Col--;
            }
        }
    }
}
